﻿using System;
using System.Text;
using System.Threading.Tasks;

using Xc.DataAccess.Core;

namespace Xc.DataAccess.HyperTerminalCore.Models
{
    public interface IClientInfo<TType>
    {
        string IpAddress { get; }
        int ReceiveCount { get; }
        int SendCount { get; }
        /// <summary>
        /// 编码方式
        /// </summary>
        Encoding Encoding { get; set; }

        event Action<TType> OnClose;
        event Action<byte[], TType, Encoding> ReceiveMessage;

        void BeginRead();
        void Close();
        Task<ResultData<T>> ReadDataByTemplate<T>(int timeout, Func<byte[], ResultData<T>> func) where T:class,new();
        Task<Result> Send(byte[] buffer);
        Task<Result> Send(string content, bool isAppendLine);
    }
}